package com.zhuiyun.pm.client.sc.controller;

import com.zhuiyun.pm.client.sc.entity.ClientTable;
import com.zhuiyun.pm.client.sc.service.servicelmpl.TableServiceImpl;
import com.zhuiyun.pm.config.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName AddressController
 * Description T0D0
 * Author Administrator
 * @Date 2023/3/14
 * Version 1.0
 **/
@RestController
@RequestMapping("table")
@CrossOrigin
public class TableController {
    @Autowired
    TableServiceImpl orderServiceImpl;

    /**
     * 根据中间表查询数据
     * @author 温
     * @date 2023/3/15 15:39
     * @parameter [clientTable]
     * @return com.zhuiyun.pm.config.CommonResult
     */
    @GetMapping("/tableList")
    public CommonResult tableList(Integer userId){
        List<ClientTable> clientTables = orderServiceImpl.TableList(userId);
        return CommonResult.ok(clientTables);
    }
    /**
     * @description:搜藏
     * @author: dongdong
     * @date: 2023/3/17 12:03
     * @param: [userId, goodsNumber]
     * @return: com.zhuiyun.pm.config.CommonResult
    **/
    @GetMapping("/collect")
    public CommonResult collect(Integer userId,Integer goodsid){
        orderServiceImpl.collect(userId,goodsid);
        return CommonResult.ok();
    }
    /**
     * @description:石否搜藏
     * @author: dongdong
     * @date: 2023/3/17 12:03
     * @param: [userId, goodsNumber]
     * @return: com.zhuiyun.pm.config.CommonResult
     **/
    @GetMapping("/selectCollect")
    public CommonResult selectCollect(Integer userId,Integer goodsid){
        return orderServiceImpl.selectCollect(userId,goodsid);
    }
    @GetMapping("/delCollect")
    public CommonResult delCollect(Integer userId,Integer goodsid){
        orderServiceImpl.delCollect(userId,goodsid);
        return CommonResult.ok();
    }
}